﻿using System;

namespace Shell.PocoDot.Configurations
{
    internal static class ConfigurationHelper
    {
        public static void Check(ProviderConfiguration pconfig,
            string defaultProviderInvariantName, string defaultProviderManifestToken)
        {
            if (pconfig == null)
            {
                throw new ArgumentNullException("pconfig.Provider");
            }
            if (String.IsNullOrWhiteSpace(pconfig.ConnectionStringOrName))
            {
                throw new ArgumentNullException("pconfig.Provider.ConnectionStringOrName");
            }
            if (String.IsNullOrWhiteSpace(pconfig.ProviderInvariantName))
            {
                pconfig.ProviderInvariantName = defaultProviderInvariantName;
            }
            if (String.IsNullOrWhiteSpace(pconfig.ProviderManifestToken))
            {
                pconfig.ProviderManifestToken = defaultProviderManifestToken;
            }
        }
    }
}
